package dubbot

import (
	"context"
	dubboc "dubbo.apache.org/dubbo-go/v3/config"
	"github.com/hyperway/pkg/component"
)

type (
	DubboTransporterLifecycle int
)

func NewDubboTransporterLifecycle() *DubboTransporterLifecycle {
	return new(DubboTransporterLifecycle)
}

func (d *DubboTransporterLifecycle) Title() string {
	return "dubbo-transporter"
}

func (d *DubboTransporterLifecycle) OnPrepare() error {
	transporter := newTransporter()
	component.RegisterTransporter(transporter)
	return loadConsumerConfig()
}

func (d *DubboTransporterLifecycle) OnDestroy(ctx context.Context) error {
	dubboc.BeforeShutdown()
	return nil
}
